package com.heisenhub.api.systemapi.fallback;

import com.heisenhub.api.systemapi.UserService;
import com.heisnenhub.common.module.entity.SystemUser;
import com.heisnenhub.common.module.utils.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author sen
 * @description
 * @date 2023/12/18 17:32
 */
@Slf4j
@Component
public class UserServiceFallback implements FallbackFactory<UserService> {

    @Override
    public UserService create(Throwable throwable) {
        log.info("【调用User 异常】 {}" ,throwable);
        return new UserService() {
            @Override
            public Api LoginByName(String username) {
                return Api.fail("调用User [‘LoginByName’] 服务出错");
            }

            @Override
            public Api<SystemUser> LoginByMobile(String mobile) {
                return Api.fail("调用User [‘LoginByMobile’] 服务出错");
            }

        };
    }
}
